home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Scripts / SysConfig.vu < prev    next >
Encoding:
Text File  |  1993-12-17  |  10.0 KB  |  278 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        SysConfig.vu
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    Naga
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #        <13>    12/17/93    KTA        Changed gFileToolOutput to gTestCaseLoggingMethod.
  19. #        <12>     12/3/93    ML        Removed PrintSystemFilesRecord().  Simplified and renamed
  20. #                                    CallOnTarget() to SystemFileInfo().  Created SystemFolderInfo().
  21. #                                    Generalized and renamed WriteTargetRecords() to
  22. #                                    WriteTargetInfo().
  23. #        <11>     12/1/93    ML        Fixed bug in outputting of MachineType, FPUtype, and MMUtype if
  24. #                                    both notebook and filetool output are desired
  25. #        <10>    11/30/93    ML        Replaced CPUType with MachineType
  26. #         <9>     9/23/93    KTA        Only write target records to notebook if gNoteBookOutPut = 1.
  27. #         <8>     9/22/93    KTA        Removed an undefined globList
  28. #         <6>     8/24/93    KTA        Removed more info that was related to the Globals Field.
  29. #         <5>     8/24/93    KTA        Removed Globals Field from target block and put it into the
  30. #                                    Suite Block.
  31. #         <4>     8/24/93    KTA        Removed a colon from the System Files block opener.
  32. #         <3>     8/20/93    KTA        Changes to support new Phoenix data format.
  33. #         <2>     6/16/93    NAGA        Renaming InitGlobals(ScriptLevel)to InitGlobals(ScriptLevel)
  34. #
  35. # ****************************************************************************
  36. #
  37.  
  38. Libraries "Globals.Lib", "OnTarget.Lib", "TCS.Lib", "FileTool.Lib", "Gestalt.Lib", "Output.Lib";
  39.  
  40. #########################################################################
  41. #                        LogSystemFilesRecord(theFolderList, FolderName)
  42. #========================================================================
  43. # Author:        KTA
  44. # Description:    This task is used to print the list returned from the OnTarget
  45. #                'vers' service.  All output will be directed to the TargetRecordsFile.
  46. #                This data will be formatted specifically for Phoenix.
  47. # Parameters:    theFolderList - list returned from call to OnTarget - 'vers' service
  48. #                FolderName - the name of the special folder that the 'vers' service
  49. #                            returned info for.
  50. # Returns:        Nada
  51. # Examples:        ExtensionsList := OnTarget('vers','system','extn'); 
  52. #                LogSystemFilesRecord(ExtensionsList , 'extn');
  53. # Assumptions:    TargetRecordsFile - is a global thathas been predefined
  54. #========================================================================
  55. # History:
  56. #
  57. #########################################################################
  58. task LogSystemFilesRecord(theFolderList := 0, FolderName := '')
  59. begin
  60.     global TargetRecordsFile;
  61.     if(theFolderList)
  62.     begin
  63.         for each TargetRecord in theFolderList
  64.         begin
  65.             FolderNameString := "            FolderName    :    {FolderName}∂n";
  66.             Title             := "            Title        :    " + TargetRecord[1] + "∂n";
  67.             TypeString         := "            Type        :    " + TargetRecord[2] + "∂n";
  68.             VersionString     := "            Version        :    " + TargetRecord[3] + "∂n";
  69.             Appersands         := "        &&∂n";
  70.             theString         := FolderNameString + Title + TypeString + VersionString + Appersands;
  71.             myreturn := WriteToFile(TargetRecordsFile, theString);
  72.         end;
  73.     end;
  74.     else
  75.         println "TheFolderList input parameter was not valid";
  76. end;
  77.  
  78. #########################################################################
  79. #                        SystemFileInfo(pFileType)
  80. #========================================================================
  81. # Author:        KTA
  82. # Description:    This task is used to call Ontarget for system file info 
  83. #                and check for errors.
  84. # Parameters:    pFileType - 'extn' - extension information
  85. #                            'ctrl' - control panel information
  86. #                            'macs' - info on files in the system folder root
  87. # Returns:        0 - Something failed
  88. #                Data - anything Ontarget returns
  89. # Examples:        CallOnTarget({'vers','system','extn'});
  90. # Assumptions:    Call InitOntarget first
  91. #========================================================================
  92. # History:
  93. #    ML    12/2/93    renamed task, renamed and simplified parameter
  94. #########################################################################
  95. Task SystemFileInfo( pFileType )
  96. begin
  97.     specialFolder := pFileType;
  98.     # LogStr("Calling Ontarget 'vers' service for info on '{specialFolder}' folder"); 
  99.     Result := OnTarget( 'vers','system', specialFolder );
  100.     if (Result[1] <> 0)        # Check for errors
  101.     begin
  102.         Println "Error during OnTarget call";
  103.         Println "Error - ", Result[1], " ", Result[3];
  104.         Return 0;
  105.     end;
  106.     else
  107.     begin
  108.         return Result[2];
  109.     end;
  110. end;
  111.  
  112. #########################################################################
  113. #                        SystemFolderInfo(printSystemFolderInfo)
  114. #========================================================================
  115. # Author:        ML
  116. # Description:    Gets and return info on system folder
  117. # Parameters:    printSystemFolderInfo - print out the info
  118. # Returns:        lists of system files and info
  119. #                0 if OnTarget unsuccessful
  120. # Examples:        SystemFolderInfo();
  121. # Assumptions:    OnTarget installed on target
  122. #========================================================================
  123. # History:
  124. #
  125. #########################################################################
  126. task SystemFolderInfo( printSystemFolderInfo:=0 )
  127. begin
  128.  
  129.     x:= OnTarget('Initialize',1);
  130.     if x[1] = 0 # if OnTarget successful
  131.     begin
  132.     
  133.         #### Extensions
  134.         ExtensionsList                 := { "Extensions", SystemFileInfo('extn') };
  135.         
  136.         #### ControlPanels
  137.         ControlPanelsList             := { "Control Panels", SystemFileInfo('ctrl') };
  138.         
  139.         #### System Folder Root Files
  140.         SystemFolderRootFilesList     := { "System Folder Root Files", SystemFileInfo('macs') };
  141.         
  142.         OnTarget('Quit');
  143.         
  144.         returnVal := {ExtensionsList, ControlPanelsList, SystemFolderRootFilesList};
  145.         
  146.         if printSystemFolderInfo
  147.         begin
  148.             println;
  149.             for each item in returnVal
  150.             begin
  151.                 println item[1],":";
  152.                 println;
  153.                 for each subitem in item[2]
  154.                     println subitem[1]," ",subitem[2]," ",subitem[3];
  155.                 println;
  156.             end; # for each item in returnVal    
  157.         end; # if printSystemFolderInfo
  158.  
  159.     end; # if OnTarget successful
  160.     
  161.     else # if OnTarget NOT successful
  162.     begin
  163.         println "Problem initializing OnTarget";
  164.         returnval := 0;
  165.     end; # if OnTarget NOT successful
  166.  
  167.     return(returnval);
  168.  
  169. end;
  170.  
  171. #########################################################################
  172. #                        WriteTargetInfo()
  173. #========================================================================
  174. # Author:        KTA
  175. # Description:    This task is write target records
  176. # Parameters:    none
  177. # Returns:        nada
  178. # Examples:        WriteTargetInfo();
  179. # Assumptions:     
  180. #========================================================================
  181. # History:
  182. #    ML    12/2/93    Generalized to output either target records to Phoenix
  183. #                if gTestCaseLoggingMethod turned on or target information to the
  184. #                notebook if gNoteBookOutput turned on.
  185. #                Revised to call SystemFolderInfo() task.
  186. #                Renamed task to reflect more general nature.
  187. #########################################################################
  188. Task WriteTargetInfo()
  189. begin
  190.     global gTestCaseLoggingMethod, gNoteBookOutput;
  191.     
  192.     specialChar := "π†";
  193.     semiColon   := "; ";
  194.     
  195.     
  196.     theMachineState := MachineState();
  197.     MachineType     := assoc('MachineType', theMachineState);
  198.     MMUType         := assoc('MMUType', theMachineState);
  199.     FPUType            := assoc('FPUType', theMachineState);
  200.     
  201.     theSystemFolderInfo := SystemFolderInfo();
  202.     if theSystemFolderInfo
  203.     begin
  204.         ExtensionsList                :=    assoc('Extensions', theSystemFolderInfo);
  205.         ControlPanelsList            :=    assoc('Control Panels', theSystemFolderInfo);
  206.         SystemFolderRootFilesList    :=    assoc('System Folder Root Files', theSystemFolderInfo);
  207.     end;
  208.     
  209.     match[target t:?targName];
  210.     match[system v:?myVersion s:?myScript];
  211.     
  212.     if (gTestCaseLoggingMethod = 1)
  213.     begin
  214.         global gFileToolOutputFile, gFileToolOutputTempFile,gMachineName, gTCSOutputPath;
  215.         SetUpOutput();
  216.         global TargetRecordsFile := "{gTCSOutputPath}{gMachineName}.TargetRecords";        # Define TargetRecords File variable
  217.         CreateTargetRecords := ExistsOrCreate(TargetRecordsFile);        # Create the file
  218.         if( CreateTargetRecords)    # Could we enable the file to exist
  219.         begin
  220.             LogStr( "Target Records will be written to the '{TargetRecordsFile}' file");
  221.             
  222.             if( CreateTargetRecords = 1)    # File already Existed
  223.                 EraseFile( TargetRecordsFile );
  224.         
  225.             TargetName             :=     "        TargetName:    {targName}∂n";            # TargetName
  226.             SuiteBlockOpener     :=     "        SYSTEM FILES    [∂n";                # TargetName
  227.             
  228.             theString :=  TargetName + SuiteBlockOpener;
  229.             myreturn := WriteToFile(TargetRecordsFile, theString);
  230.             if(myreturn[1] <> 0)
  231.             begin
  232.                 LogStr( "Problem writing to file {TargetRecordsFile}");
  233.                 Println "    Error : ", myreturn[1], "  ", myreturn[3];
  234.                 Println "Turning NoteBook output - ON, since FileTool output failed";
  235.                 gNoteBookOutput := 1;
  236.             end;
  237.             else
  238.             begin
  239.             
  240.                 if ExtensionsList
  241.                     LogSystemFilesRecord(ExtensionsList , 'extn');                        # Items in Special Folders
  242.                 if ControlPanelsList
  243.                     LogSystemFilesRecord(ControlPanelsList , 'ctrl');
  244.                 if SystemFolderRootFilesList
  245.                     LogSystemFilesRecord(SystemFolderRootFilesList , 'macs');
  246.             
  247.         
  248.                 SuiteBlockCloser     :=     "        ]∂n";            # TargetName
  249.                 ScriptSys             := "        ScriptSys:    {myScript}∂n";
  250.                 ScriptVers             := "        ScriptVers:    {myVersion}∂n";
  251.                 myMachineType             := "        MachineType:{MachineType}∂n";                # MachineType
  252.                 myMMUType                 := "        MMUType:    {MMUType}∂n";                # MMUType
  253.                 myFPUType                 := "        FPUType:    {FPUType}∂n";                # FPUType
  254.                 Appersands             := "    &&∂n";
  255.                 
  256.                 theString := SuiteBlockCloser + ScriptSys + ScriptVers + myMachineType + myMMUType + myFPUType + Appersands;
  257.                 myreturn := WriteToFile(TargetRecordsFile, theString);
  258.             end;
  259.         end; # if (gTestCaseLoggingMethod)
  260.         else
  261.         begin
  262.             println "Couldn't create TargetRecords file";
  263.             Println "Turning NoteBook output - ON, since FileTool output failed";
  264.             gNoteBookOutput := 1;
  265.         end;
  266.     end; # if (global gTestCaseLoggingMethod)
  267.     
  268.     if (global gNoteBookOutput)
  269.     begin
  270.         InitTCSLogging(); # remove when Gestalt globals decoupled from this task
  271.         MachineState(1);
  272.         SystemFolderInfo(1);
  273.     end; # if (global gNoteBookOutput)
  274.     
  275. end; # WriteTargetRecords()
  276.  
  277. InitGlobals();
  278. WriteTargetInfo();